<template>
    <div class="abnormal-manage">
        <!-- 筛选条件 学生角色登录隐藏-->
        <condition-card
            v-if="!global.isStudent"
            @search="filetrCondition"
            @reset="reset"
            @getIsExpand="getIsExpand"
            :expand="global.isStudent ? false : true"
        >
            <el-row :gutter="24">
                <template v-if="global.isStudent && !isExpand">
                    <el-col :span="8">
                        <el-form-item label="异动大类">
                            <DictSelect
                                labelAll="请选择"
                                v-model="query.classId"
                                :data="options.classId"
                                @change="handlerClassIdChange"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="异动类型">
                            <DictSelect
                                labelAll="请选择"
                                v-model="query.typeId"
                                :data="options.typeId"
                                @change="handlerAbnormalType"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                </template>
                <el-col :span="8">
                    <el-form-item label="年级">
                        <el-date-picker
                            style="width: 100%;"
                            v-model="query.currentGrade"
                            type="year"
                            value-format="yyyy"
                            placeholder="请选择"
                            @change="
                                currentDptId === '1'
                                    ? handleChangeFaculty()
                                    : ''
                            "
                            :picker-options="pickerOptions"
                        ></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="学院">
                        <DictSelect
                            labelAll="请选择"
                            v-model="multipleQuery.currentFaculty"
                            :data="options.faculty"
                            @change="handleChangeFaculty"
                            multiple
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="培养专业">
                        <DictSelect
                            labelAll="请选择"
                            v-model="multipleQuery.currentProfession"
                            :data="options.profession"
                            multiple
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="培养层次">
                        <DictSelect
                            labelAll="请选择"
                            v-model="multipleQuery.trainingLevel"
                            :data="options.trainingLevel"
                            multiple
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="培养类别">
                        <DictSelect
                            labelAll="请选择"
                            v-model="query.trainingCategory"
                            :data="options.trainingCategory"
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="学位类型">
                        <DictSelect
                            labelAll="请选择"
                            v-model="query.degreeType"
                            :data="options.degreeType"
                            @change="
                                currentDptId !== '1'
                                    ? handleChangeFaculty()
                                    : ''
                            "
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="学习形式">
                        <DictSelect
                            labelAll="请选择"
                            v-model="query.formLearning"
                            :data="options.formLearning"
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <template v-if="!global.isStudent || isExpand">
                    <el-col :span="8">
                        <el-form-item label="异动大类">
                            <DictSelect
                                labelAll="请选择"
                                v-model="query.classId"
                                :data="options.classId"
                                @change="handlerClassIdChange"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="异动类型">
                            <DictSelect
                                labelAll="请选择"
                                v-model="query.typeId"
                                :data="options.typeId"
                                @change="handlerAbnormalType"
                            ></DictSelect>
                        </el-form-item>
                    </el-col>
                </template>
                <el-col :span="8">
                    <el-form-item label="异动原因">
                        <DictSelect
                            labelAll="请选择"
                            v-model="query.reasonName"
                            :data="options.reasonName"
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="审核状态">
                        <DictSelect
                            labelAll="请选择"
                            v-model="query.status"
                            :data="options.abnormalList"
                        ></DictSelect>
                    </el-form-item>
                </el-col>
                <!-- 国际生 -->
                <el-col :span="8">
                        <el-form-item label="是否国际生" >
                                <el-select
                                    v-model="query.internationalStudent"
                                    style="width:100%"
                                    clearable
                                >
                                    <el-option
                                        v-for="item in options.isOverseas"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="异动时间">
                        <el-row type="flex" justify="center" align="middle">
                            <el-date-picker
                                v-model="query.abnormalStartTime"
                                value-format="timestamp"
                                type="date"
                                placeholder="选择日期"
                            ></el-date-picker>
                            <span style="margin: 0 10px;">~</span>
                            <el-date-picker
                                v-model="query.abnormalEndTime"
                                type="date"
                                value-format="timestamp"
                                placeholder="选择日期"
                            ></el-date-picker>
                        </el-row>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="审核时间">
                        <el-row type="flex" justify="center" align="middle">
                            <el-date-picker
                                v-model="query.operateStartTime"
                                value-format="timestamp"
                                type="date"
                                placeholder="选择日期"
                            ></el-date-picker>
                            <span style="margin: 0 10px;">~</span>
                            <el-date-picker
                                v-model="query.operateEndTime"
                                type="date"
                                value-format="timestamp"
                                placeholder="选择日期"
                            ></el-date-picker>
                        </el-row>
                    </el-form-item>
                </el-col>
            </el-row>
        </condition-card>
        <el-card shadow="never">
            <h2>学籍异动管理</h2>
            <el-row class="border-bt mb-8px" v-if="!global.isStudent"><!-- 学生角色登录隐藏 -->
                <el-radio-group
                    v-model="query.classId"
                    class="mb-8px"
                    @change="handlerClassIdChange"
                >
                    <el-radio-button label>全部</el-radio-button>
                    <el-radio-button
                        v-border
                        class="mb-8px"
                        :label="item.value"
                        v-for="(item, index) in options.classId"
                        :key="index"
                        >{{ item.label }}</el-radio-button
                    >
                </el-radio-group>
            </el-row>
            <el-row type="flex" align="middle" class="mb-8px">
                <el-col v-if="!global.isStudent" class="text-left">
                    <KeywordInput
                        v-model="query.keyWord"
                        @enter="getAbnormalList"
                        placeholder="请输入学生学号/姓名搜索"
                    ></KeywordInput>
                </el-col>
                <el-col class="text-right">
                  <el-button type="primary" v-if="notStudent && authRight.auditAll" @click="auditAll">批量审核</el-button>
                    <el-dropdown
                        trigger="click"
                        @command="handleImportCommand"
                        v-if="(global.isAdmin || global.isAcdemicDean) && !overSeas && authRight.importAll"
                    >
                        <el-button>
                            批量导入
                            <i class="el-icon-arrow-down el-icon--right"></i>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item command="import"
                                >导入</el-dropdown-item
                            >
                            <el-dropdown-item command="download"
                                >下载模板</el-dropdown-item
                            >
                        </el-dropdown-menu>
                    </el-dropdown>
                    <!-- /api/studentservice/apply/importApply -->

                    <el-upload
                        action="/api/studentservice/apply/getFileData"
                        style="display: none;"
                        ref="upload"
                        :file-list="uploadConfig.fileList"
                        :on-success="handlerSuccess"
                        :on-error="handlerError"
                        :before-upload="beforeUpload"
                        :auto-upload="true"
                        :show-file-list="false"
                    >
                        <span slot="trigger" ref="importBtn">离校导入</span>
                    </el-upload>
                    <el-dropdown trigger="click" @command="handleExportCommand">
                        <el-button
                        v-if="authRight.exportAll"
                        >
                            批量导出
                            <i class="el-icon-arrow-down el-icon--right"></i>
                            
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item command="applyList"
                                >异动申请列表</el-dropdown-item
                            >
                            <el-dropdown-item
                                command="studentStatusList"
                                v-if="!global.isUndergraduate"
                                >学籍异动申请表</el-dropdown-item
                            >
                            <el-dropdown-item
                                command="studentStatusNotification"
                                v-if="!global.isUndergraduate"
                                >学籍异动通知单</el-dropdown-item
                            >
                            <el-dropdown-item command="enrolment"
                                >在校学籍异动DBF</el-dropdown-item
                            >
                            <el-dropdown-item command="revoked"
                                >注销学籍异动DBF</el-dropdown-item
                            >
                            <el-dropdown-item command="underStatusNotification" v-if="global.isUndergraduate"
                                >学籍异动通知单</el-dropdown-item
                            >
                        </el-dropdown-menu>
                    </el-dropdown>
                    <!-- <el-button>高级导出</el-button> -->
                    <!-- <el-button v-if="!global.isStudent" @click="operate(null,2)">批量审核</el-button> -->
                    <el-button
                        v-if="global.isStudent && authRight.apply"
                        type="primary"
                        @click="applyAbnormal"
                        >申请</el-button
                    >
                </el-col>
            </el-row>
            <edu-table
                ref="tables"
                :order="false"
                :data="abnormalManageList.data"
                :total="abnormalManageList.total"
                @page-change="pageChange"
                :pageNum="query.pageNum_"
                @selection-change="handleSelectionChange"
                :selectFixed="true"
                :page-sizes="[10, 20, 50, 100, 500, 1000]"
            >
              <!-- 本科生 -->
              <template v-if="isUndergraduate()">
                <el-table-column label="学号" width="100" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.studentId }}
                    </template>
                </el-table-column>
                <el-table-column label="姓名" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.studentName }}
                    </template>
                </el-table-column>
                <el-table-column label="异动大类" show-overflow-tooltip  width="120">
                    <template slot-scope="scope">
                        {{ scope.row.classIdI18n }}
                    </template>
                </el-table-column>
                <el-table-column label="异动类型" show-overflow-tooltip width="120">
                    <template slot-scope="scope">
                        {{ scope.row.typeName }}
                    </template>
                </el-table-column>
                <el-table-column label="异动原因" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.reasonName }}
                    </template>
                </el-table-column>
                <el-table-column
                  label="异动时间"
                  show-overflow-tooltip
                  width="110"
                >
                    <template slot-scope="scope">
                        {{ scope.row.effectiveTimeFormart }}
                    </template>
                </el-table-column>
                <el-table-column label="年级" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.currentGrade }}
                    </template>
                </el-table-column>
                <el-table-column label="学院" show-overflow-tooltip width="180">
                    <template slot-scope="scope">
                        {{ scope.row.currentFacultyI18n }}
                    </template>
                </el-table-column>
                <el-table-column label="培养专业" show-overflow-tooltip width="200" v-if="this.global.projectId == '1'">
                    <template slot-scope="scope">
                        {{ scope.row.currentProfessionName }}
                    </template>
                </el-table-column>
                <el-table-column label="培养专业" show-overflow-tooltip width="200" v-else-if="this.global.projectId == '2'">
                    <template slot-scope="scope">
                        {{scope.row.currentProfessionI18n}}
                    </template>
                </el-table-column>
                <el-table-column label="学籍专业" show-overflow-tooltip   width="200" v-if="global.isUndergraduate">
                    <template slot-scope="scope">
                        {{ scope.row.statusProfessionName }}
                    </template>
                </el-table-column>
                <el-table-column label="专业方向名称" show-overflow-tooltip width="120px">
                <template slot-scope="scope">
                  {{ scope.row.majorDirectionName }}
                </template>
              </el-table-column>
                <el-table-column label="培养层次" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.trainingLevelI18n }}
                    </template>
                </el-table-column>
                <el-table-column label="培养类别" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.trainingCategoryI18n }}
                    </template>
                </el-table-column>
                <el-table-column label="学位类型" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.degreeTypeI18n }}
                    </template>
                </el-table-column>
                <el-table-column label="学习形式" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.formLearningI18n }}
                    </template>
                </el-table-column>
                <el-table-column
                  label="导师"
                  show-overflow-tooltip
                  min-width="120px"
                >
                    <template slot-scope="scope">
                        {{ scope.row.teacherName }}
                    </template>
                </el-table-column>
                <el-table-column label="审核状态" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.status | getStatus }}
                    </template>
                </el-table-column>
                <el-table-column
                  label="审核时间"
                  show-overflow-tooltip
                  width="120"
                >
                    <template slot-scope="scope">
                        {{ scope.row.approvedTime }}
                    </template>
                </el-table-column>
                <el-table-column
                  label="当前处理人"
                  show-overflow-tooltip
                  width="120"
                >
                    <template slot-scope="scope">
                        <el-button
                          :disabled="
                                scope.row.operatInfo &&
                                    scope.row.operatInfo.type !== 1
                            "
                          type="text"
                          @click="showUserGroup(scope.row.approveId)"
                        >{{
                                (scope.row.operatInfo &&
                                    scope.row.operatInfo.name) ||
                                    ""
                            }}</el-button
                        >
                    </template>
                </el-table-column>
                <el-table-column label="操作" fixed="right" width="140">
                    <template slot-scope="scope">
                        <template v-if="scope.row.status !== '0'">
                            <el-button
                              type="text"
                              v-if="scope.row.status === '2' && !global.isAnyTeacher && authRight.edit"
                              @click="operate(scope.row, 4)"
                            >编辑</el-button
                            >
                            <el-button
                              type="text"
                              @click="operate(scope.row, 1)"
                              v-if="authRight.view"
                            >查看</el-button
                            >
                            <el-button
                              type="text"
                              v-if="scope.row.revocateBtnStatus && authRight.revoke"
                              @click="operate(scope.row, 3)"
                            >撤销</el-button
                            >
                            <el-button
                              type="text"
                              v-if="
                                    (scope.row.status === '4' ||
                                        scope.row.status === '5' ||
                                        scope.row.status === '6' ||
                                        scope.row.status === '7' ||
                                        scope.row.status === '8' ||
                                        scope.row.status === '10'
                                        ) &&
                                        String(scope.row.approveFlag) == 'true'
                                        && authRight.audit
                                "
                              @click="operate(scope.row, 2)"
                            >审核</el-button
                            >
                            <el-button
                              type="text"
                              @click="deleteApply(scope.row)"
                              v-if="authRight.del && (scope.row.status == '0' || scope.row.status == '2' || scope.row.status == '9')"
                            >删除</el-button
                            >
                        </template>
                        <template v-else>
                            <el-button
                              type="text"
                              @click="operate(scope.row, 0)"
                              v-if="authRight.edit && (scope.row.status == '0' || scope.row.status == '9')"
                            >编辑</el-button
                            >
                            <el-button
                              type="text"
                              @click="operate(scope.row, 1)"
                              v-if="authRight.view"
                            >查看</el-button
                            >
                            <el-button
                              type="text"
                              @click="deleteApply(scope.row)"
                              v-if="authRight.del && (scope.row.status == '0' || scope.row.status == '2' || scope.row.status == '9')"
                            >删除</el-button
                            >
                        </template>
                    </template>
                </el-table-column>
              </template>
              <!-- 研究生 -->
              <template v-if="isGraduateStudent()">
                <el-table-column label="学号" width="100" prop="studentId" show-overflow-tooltip/>
                <el-table-column label="姓名" width="100" prop="studentName" show-overflow-tooltip/>
                <el-table-column label="学院" width="160" prop="currentFacultyI18n" show-overflow-tooltip v-if="isShowFaculty()"/>
                <el-table-column label="专业" width="100" prop="currentProfessionI18n" show-overflow-tooltip/>
                <el-table-column label="层次" width="100" prop="trainingLevelI18n" show-overflow-tooltip/>
                <el-table-column label="导师" width="140" prop="teacherName" show-overflow-tooltip/>
                <el-table-column label="异动原因" width="130" prop="reasonName" show-overflow-tooltip/>
                <el-table-column label="异动大类" width="130" prop="classIdI18n" show-overflow-tooltip/>
                <el-table-column label="异动类型" width="120" prop="typeName" show-overflow-tooltip/>
                <el-table-column label="审核状态" width="100" prop="studentId" show-overflow-tooltip>
                   <template slot-scope="scope">
                        {{ scope.row.status | getStatus }}
                    </template>
                </el-table-column>
                <el-table-column label="当前处理人" width="140" prop="studentId" show-overflow-tooltip>
                  <template slot-scope="scope">
                        <el-button
                          :disabled="
                                scope.row.operatInfo &&
                                    scope.row.operatInfo.type !== 1
                            "
                          type="text"
                          @click="showUserGroup(scope.row.approveId)"
                        >{{
                                (scope.row.operatInfo &&
                                    scope.row.operatInfo.name) ||
                                    ""
                            }}</el-button
                        >
                    </template>
                </el-table-column>
                <el-table-column label="年级" width="100" prop="currentGrade" show-overflow-tooltip/>
                <el-table-column label="培养类别" width="100" prop="trainingCategoryI18n" show-overflow-tooltip/>
                <el-table-column label="学习形式" width="100" prop="formLearningI18n" show-overflow-tooltip/>
                <el-table-column label="操作" fixed="right" width="150">
                    <template slot-scope="scope">
                        <template v-if="scope.row.status !== '0'">
                            <el-button
                              type="text"
                              v-if="scope.row.status === '2' && authRight.edit"
                              @click="operate(scope.row, 4)"
                            >编辑</el-button
                            >
                            <el-button
                              type="text"
                              @click="operate(scope.row, 1)"
                              v-if="authRight.view"
                            >查看</el-button
                            >
                            <el-button
                              type="text"
                              v-if="scope.row.revocateBtnStatus && authRight.revoke"
                              @click="operate(scope.row, 3)"
                            >撤销</el-button
                            >
                            <el-button
                              type="text"
                              v-if="
                                    (scope.row.status === '4' ||
                                        scope.row.status === '5' ||
                                        scope.row.status === '6' ||
                                        scope.row.status === '7' ||
                                        scope.row.status === '8' ||
                                        scope.row.status === '10'
                                        ) &&
                                        String(scope.row.approveFlag) == 'true'
                                        && authRight.audit
                                "
                              @click="operate(scope.row, 2)"
                            >审核</el-button
                            >
                            <el-button
                              type="text"
                              @click="deleteApply(scope.row)"
                              v-if="authRight.del && (scope.row.status == '0' || scope.row.status == '2' || scope.row.status == '9')"
                            >删除</el-button
                            >
                        </template>
                        <template v-else>
                            <el-button
                              type="text"
                              @click="operate(scope.row, 0)"
                              v-if="authRight.edit && (scope.row.status == '0' || scope.row.status == '9')"
                            >编辑</el-button
                            >
                            <el-button
                              type="text"
                              @click="operate(scope.row, 1)"
                              v-if="authRight.view"
                            >查看</el-button
                            >
                            <el-button
                              type="text"
                              @click="deleteApply(scope.row)"
                              v-if="authRight.del && (scope.row.status == '0' || scope.row.status == '2' || scope.row.status == '9')"
                            >删除</el-button
                            >
                        </template>
                    </template>
                </el-table-column>
              </template>
            </edu-table>
        </el-card>
        <el-dialog
            v-drag-dialog
            title="组内用户明细"
            :visible.sync="showUserGroupDialog"
        >
            <edu-table
                :total="queryUserForm.total"
                @page-change="pageChangeDialog"
                :data="usersUnderGroup"
                :selection="false"
            >
                <el-table-column label="账号">
                    <template slot-scope="scope">
                        {{ scope.row.studentId }}
                    </template>
                </el-table-column>
                <el-table-column label="用户名">
                    <template slot-scope="scope">{{ scope.row.name }}</template>
                </el-table-column>
                <el-table-column label="联系电话">
                    <template slot-scope="scope">
                        {{ scope.row.phoneNumber }}
                    </template>
                </el-table-column>
                <el-table-column label="联系邮箱" min-width="150">
                    <template slot-scope="scope">
                        {{ scope.row.email }}
                    </template>
                </el-table-column>
                <el-table-column label="类型">
                    <template slot-scope="scope">
                        {{
                            scope.row.userType == "1"
                                ? "老师"
                                : scope.row.userType == "2"
                                ? "学生"
                                : "本地用户"
                        }}
                    </template>
                </el-table-column>
            </edu-table>
        </el-dialog>
      <el-dialog title="批量审核" width="60%" :visible.sync="dialogFlag1" v-if="dialogFlag1" :close-on-click-modal="false">
        <el-form ref="form" :model="form" label-width="100px" :rules="rules">
          <el-form-item label="审核意见：">
            <el-input type="textarea" rows="4" v-model.trim="form.auditRemark" maxlength="200" resize="none"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFlag1=false">取消</el-button>
          <el-button type="danger" @click="audit('reject')">驳回</el-button>
          <el-button type="primary" @click="audit('pass')">通过</el-button>
        </div>
      </el-dialog>
      <el-dialog title="导入"  width="70%" min-width="1200px" :visible.sync="importSure"  :close-on-click-modal="false">
          <edu-table
                    :pagination="false"
                    :order="true"
                    :tooltipEffect="tooltipEffect"
                    stripe
                    :data="dataList"
                    :selection="false"
                    size="mini"
                >
                    <edu-table-column
                        label="学号"
                        prop="studentId"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="异动大类"
                        prop="className"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="异动类型"
                        prop="typeName"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="异动原因"
                        prop="reasonName"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="原因说明"
                        prop="remark"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="异动开始时间"
                        prop="abnormalStartTime"
                        align="left"
                        width="120px"
                    ></edu-table-column>
                    <edu-table-column
                        label="异动结束时间"
                        prop="abnormalEndTime"
                        align="left"
                        width="120px"
                    ></edu-table-column>

                    <edu-table-column
                        label="在校状态"
                        prop="leaveSchool"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="培养类别"
                        prop="trainingCategory"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="学籍状态"
                        prop="registrationStatus"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="离校时间"
                        prop="offSchool"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="预计毕业时间"
                        prop="expectedGraduationDate"
                        align="left"
                        width="120px"
                    ></edu-table-column>
                    <edu-table-column
                        label="入学时间"
                        prop="enrolDate"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="入学季节"
                        prop="enrolSeason"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="当前年级"
                        prop="currentGrade"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="学院"
                        prop="faculty"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="培养专业"
                        prop="cultureProfession"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="学籍学院"
                        prop="statusFaculty"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="学籍专业"
                        prop="statusProfession"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="教师工号"
                        prop="teacherId"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="注册状态"
                        prop="registerStatus"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="培养层次"
                        prop="trainingLevel"
                        align="left"
                    ></edu-table-column>
                    <edu-table-column
                        label="学位类型"
                        prop="degreeType"
                        align="left"
                    ></edu-table-column>
          </edu-table>
          <div style="text-align: right;margin-top:20px;">
          <el-button  @click="importSure=false">取消</el-button>
          <el-button type="primary" @click="makeSureImport" :disabled='disBtn'>导入</el-button>
          </div>
      </el-dialog>
      <el-dialog title="申请此类异动需完成以下所有课程的退课，是否确定" :visible.sync="dialogTableVisible" width="900px">
        <el-table :data="gridData" style="margin-bottom: 30px">
            <el-table-column type="index"   label="序号" width="100"></el-table-column>
                <el-table-column property="studentId" label="学号" width="150"></el-table-column>
                <el-table-column property="name" label="姓名" width="150"></el-table-column>
            <el-table-column property="courseCode" label="课程序号" width="200"></el-table-column>
            <el-table-column property="courseName" label="课程名称" width="200"></el-table-column>
        </el-table>
        <div style="height: 25px;">
            <el-button type="primary" style="float:right;"   @click="auditPass()">确定</el-button>
            <el-button type="primary" style="float:right; margin-right:20px" @click="cancel()">取消</el-button>
        </div>
        </el-dialog>
    </div>
</template>
<script>
import { throughBatch, rejectBatch } from "common/src/api/studentRegister";
import { getUserInfoListByGroupId } from "common/src/api/user";
import { queryDic } from "common/src/api/dictionary";
import Calendars from "common/src/api/calendars.js";
import UTILS from "common/src/utils/utils";
import * as API from "common/src/api/abnormalType/abnormal";
import * as applyApi from "common/src/api/studentStatus/abnormalManage";
import * as abnormalApi from 'common/src/api/studentStatus/abnormalToApply'
import { deleteType } from "common/src/api/studentStatus/applicationByAcademic";
import mixin from 'common/src/mixins/index';
export default {
    name: "abnormalManage",
    mixins: [mixin],
    components: {},
    data() {
        return {
          notStudent: true,
          dialogTableVisible: false,
          gridData: [],
          form: {
            auditRemark: ''
          },
          dataList:[],
          disBtn: false,
          importFile:null,
          importSure: false,
          dialogFlag1: false,
          multipleQuery: {
              currentFaculty: [],
              currentProfession: [],
              trainingLevel: []
          },
          query: {
              currentGrade: "",
              trainingLevel: "",
              currentFaculty: "",
              currentProfession: "",
              trainingLevel: "",
              trainingCategory: "",
              degreeType: "",
              formLearning: "",
              classId: "",
              status: "",
              typeId: "",
              reasonName: "",
              abnormalStartTime: "",
              abnormalEndTime: "",
              operateStartTime: "",
              operateEndTime: "",
              keyWord: "",
              pageNum_: 1,
              pageSize_: 20,
              isStudent: "",
              currentUuid: "",
              internationalStudent:'' //是否是国际生
          },
          queryUserForm: {
              userName: "",
              pageNum_: 1,
              total: 0,
              pageSize_: 20,
              groupId: ""
          },
          options: {
              trainingLevel: [],
              faculty: [],
              profession: [],
              formLearning: [],
              degreeType: [],
              trainingCategory: [],
              classId: [],
              typeId: [],
              reasonName: [],
              abnormalList: [],
              isOverseas: [],
          },
          showUserGroupDialog: false,
          classId: "all",
          selectItems: [], //多选的列表数据
          uploadConfig: {
              fileList: []
          },
          abnormalManageList: {
              total: 0,
              data: [{ paymentStatus: "1" }]
          },
          isExpand: false, // 筛选条件是否展开
          currentDptId: "",
          usersUnderGroup: [],
          pickerOptions: {
              disabledDate(time) {
                  return (
                      time.getTime() > Date.now() ||
                      time.getTime() < new Date("1978").getTime()
                  );
              }
          },
          overSeas: false,
          termTime: {},
          authRight: {
              view:false, // 查看
              apply:false, // 申请
              edit:false, // 编辑
              del:false, // 删除
              revoke:false, // 撤回
              audit:false, // 审核
              auditAll:false, // 批量审核
              importAll:false, // 批量导入
              exportAll:false, // 批量导出
          }
        };
    },
    created() {
        this.query.isStudent = this.global.isStudent;
        if (this.mockUser) {
            this.currentDptId = this.mockUser.currentManageDptId;
            this.query.currentUuid = this.mockUser.uid;
            if(this.mockUser.currentRole !== null){
              this.notStudent = true;
            } else {
              this.notStudent = false;
            }
        } else if (this.currentUser) {
            this.currentDptId = this.currentUser.currentManageDptId;
            this.query.currentUuid = this.currentUser.uid;
        }
        if(this.$route.query.routerQuery) {
            // 出问题的地方 解析不过去 主要是查看页面的返回其实是跳转 带了一个query 的 对象体 
            this.query = _.cloneDeep(this.$route.query.routerQuery);
            typeof(this.query) === 'string' ? this.query = JSON.parse(this.query) : ''
            if(this.$route.query.routerQuery.classId) {
                this.handlerClassIdChange(this.$route.query.routerQuery.classId,'ifRouter')
            }
        }
        if(this.$route.query.extralQuery) {
            this.handleChangeFaculty(this.$route.query.extralQuery.currentFaculty);
            this.multipleQuery = _.cloneDeep(this.$route.query.extralQuery)
            typeof(this.multipleQuery) === 'string' ? this.multipleQuery = JSON.parse(this.multipleQuery) : ''
        }
        if (localStorage.getItem('sessiondata')) {
        // 获取当前用户auths权限
            if (JSON.parse(localStorage.getItem('sessiondata')).auths) {
                this.auths = JSON.parse(localStorage.getItem('sessiondata')).auths
                if (this.auths) {
                    this.auths.forEach(val => {
                        if (val.authCode === 'student-abnormal-audit') {
                            // 审核按钮权限
                            this.authRight.audit = true
                        } 
                        if (val.authCode === 'student-abnormal-apply') {
                            // 申请按钮权限
                            this.authRight.apply = true
                        } 
                        if (val.authCode === 'student-abnormal-view') {
                            // 查看按钮权限
                            this.authRight.view = true
                        } 
                        if (val.authCode === 'student-abnormal-del') {
                            // 删除按钮权限
                            this.authRight.del = true
                        } 
                        if (val.authCode === 'student-abnormal-revoke') {
                            // 撤销按钮权限
                            this.authRight.revoke = true
                        } 
                        if (val.authCode === 'student-abnormal-auditAll') {
                            // 批量审核按钮权限
                            this.authRight.auditAll = true
                        } 
                        if (val.authCode === 'student-abnormal-importAll') {
                            // 批量导入按钮权限
                            this.authRight.importAll = true
                        } 
                        if (val.authCode === 'student-abnormal-exportAll') {
                            // 批量导出按钮权限
                            this.authRight.exportAll = true
                        } 
                        if (val.authCode === 'student-abnormal-edit') {
                            // 编辑按钮权限
                            this.authRight.edit = true
                        } 
                    })
                }
            }
        }
        this.initOptions();
        this.getAbnormalList();
    },
    mounted() {
        let userData = JSON.parse(localStorage.getItem("sessiondata"));
        this.overSeas = userData.overSeas == "0";
        if(this.$route.query.extralQuery) {
            this.multipleQuery = _.cloneDeep(this.$route.query.extralQuery)
            typeof(this.multipleQuery) === 'string' ? this.multipleQuery = JSON.parse(this.multipleQuery) : ''
        }
        if(this.$route.query.routerQuery) {
            this.query = _.cloneDeep(this.$route.query.routerQuery)
            typeof(this.query) === 'string' ? this.query = JSON.parse(this.query) : ''
        }

    },
    methods: {
        // 判断是否为本科生
        isUndergraduate () {
          return this.currentDptId && this.currentDptId.toString() === '1';
        },
        // 判断是否为研究生
        isGraduateStudent () {
          const currentManageDptId = this.currentDptId && this.currentDptId.toString();
          // return currentManageDptId === '2' || currentManageDptId === '4';
          return currentManageDptId !== '1';
        },
        // 是否显示学院
        isShowFaculty() {
          const innerRoles = (this.mockUser || this.currentUser).innerRoles || [];
          return innerRoles.includes('1');
        },
        auditAll() { // 批量审核
          let selection = this.$refs.tables.selectionDatas;
          if (!selection || selection.length === 0) {
            this.$message({
              type: "warning",
              message: "至少勾选一个学生",
            });
            return;
          }
          this.dialogFlag1 = true;
          this.form.auditRemark = '';
        },
        audit(type) { // 批量审核
          /*debugger;*/
          let selection = this.$refs.tables.selectionDatas;
          let data = selection.map(r => {
            return {
              uid: r.studentId,
              no: r.workflowNo,
              content: this.form.auditRemark
            };
          });

          if (type == 'reject') {
            if (this.form.auditRemark == '') {
              this.$message({
                type: "warning",
                message: "审核意见不能为空",
              });

            } else {
            //   console.log('data:',data);
              rejectBatch(data).then(res => {
                if (res && res.code !== 200) {
                  this.$message({ message: res.msg, type: 'warning' });
                  return;
                }
                this.getAbnormalList();
                this.dialogFlag1 = false;
              });
            }
          } else {
            let parm = [];
            this.gridData = [];
              selection.forEach(r => {
                if(r.typeName === '休学' || r.typeName === '退学') {
                    parm.push({
                    studentId: r.studentId,
                    abnormalStartTimeFormart: r.abnormalStartTimeFormart,
                    })
                }
            });
            if(parm.length > 0) {
                abnormalApi.coursesInAbnormalTime(parm).then(res=> {
                    if(res.code === 200 && res.data) {
                        this.dialogTableVisible = true;
                        res.data.forEach(val=> {
                            this.abnormalManageList.data.forEach(list=> {
                                if(val.studentId === list.studentId) {
                                    this.gridData.push({
                                    name: list.studentName,
                                    studentId: list.studentId,
                                    courseName: val.courseName,
                                    courseCode: val.courseCode
                                })
                            }
                        })
                    })
                    }
                })
            } else {
                this.dialogTableVisible = false;
                this.gridData = [];
                this.auditPass()
            }


          }
        },
        auditPass() {
            let selection = this.$refs.tables.selectionDatas;
            let data = selection.map(r => {
            return {
              uid: r.studentId,
              no: r.workflowNo,
              content: this.form.auditRemark
            };
          });
            this.dialogTableVisible = false;
            this.gridData = [];
            throughBatch(data).then(res => {
              if (res && res.code !== 200) {
                this.$message({ message: res.msg, type: 'warning' });
                return;
              }
              this.getAbnormalList();
              this.dialogFlag1 = false;
            });
        },
        cancel() {
            this.dialogTableVisible = false;
            this.gridData = []

        },
        // 获取筛选条件字段下拉数据
        async initOptions() {
            try {
                const data = {
                    lang: this.$store.getters.language || "cn",
                    type: "allChild",
                    keys: [
                        "X_YX",
                        "X_PYCC",
                        "X_PYLB",
                        "X_XWLX",
                        "X_XXXS",
                        "G_XJDL",
                        'isAborad',
                    ]
                };
                const res = await queryDic(data);
                if (res.code === 200) {
                    UTILS.fillSelect(
                        {
                            faculty: "X_YX",
                            trainingLevel: "X_PYCC",
                            trainingCategory: "X_PYLB",
                            degreeType: "X_XWLX",
                            formLearning: "X_XXXS",
                            classId: "G_XJDL",
                            isOverseas:'isAborad'
                        },
                        res.data,
                        this.options
                    );
                    // console.log(this.options,'this.options');
                    let copyClassIds = this.options.classId;
                    let arrayFore = copyClassIds.filter(
                        e => e.label !== "其他"
                    );
                    let arrayBehind = copyClassIds.filter(
                        e => e.label == "其他"
                    );
                    this.options.classId = [...arrayFore, ...arrayBehind];
                }
                const resAbn = await API.getAbnormalStatus();
                if (resAbn.code == 200 && resAbn.data) {
                    this.options.abnormalList = resAbn.data.map(e => {
                        let obj = {};
                        for (var key in e) {
                            (obj.value = key), (obj.label = e[key]);
                        }
                        return obj;
                    });
                }
            } catch (err) {
                console.log(err);
            }
        },
        // 申请异动
        async applyAbnormal() {
            try {
                let studentId;
                if (this.mockUser) {
                    studentId = this.mockUser.uid;
                } else {
                    studentId = this.currentUser.uid;
                }
                //接口未调用正确
                const res = await API.queryStudentInfoByStudentId(studentId);
                if (res.code == 200) {
                    /**
                     * saveType 保存类型,用于后台区分申请保存、编辑保存
                     * 1：申请保存；2：编辑保存
                     */
                    this.$router.push({
                        path: "/moveToApply",
                        query: {
                            studentInfo: [res.data],
                            saveType: 1,
                            type: "abnormalManage"
                        }
                    });
                }
            } catch (err) {
                console.log(err);
            }
        },
        /**列表操作
         *  params row 列表的单项数据  type 0: 编辑 1:查看 2:审核/批量审核 3:撤销
         */
        operate(row, type) {
            let queryParams = {
                type: "abnormalManage",
                studentInfo: row
            };
            queryParams.routerQuery = _.cloneDeep(this.query);
            queryParams.extralQuery = _.cloneDeep(this.multipleQuery);
            /**
             * saveType 保存类型,用于后台区分申请保存、编辑保存
             * 1：申请保存；2：编辑保存
             */
            if (type == 0) {
                const params = _.cloneDeep(queryParams);
                queryParams.studentInfo = [params.studentInfo];
                queryParams.saveType = 2;
                queryParams.editType = "adminEdit";
                this.$router.push({
                    path: "/moveToApply",
                    query: queryParams
                });
            } else if (type == 4) {
                const params = _.cloneDeep(queryParams);
                params.studentInfo.id = null;
                params.studentInfo.workflowNo = null;
                queryParams.studentInfo = [params.studentInfo];
                queryParams.saveType = 1;
                this.$router.push({
                    path: "/moveToApply",
                    query: queryParams
                });
            } else if (type == 1) {
                //queryParams添加一个参数 reviewVisiable判断进入审核页的入口，控制审核页审核理由模块显示
                queryParams.reviewVisiable = false;
                queryParams.type = "view";
                this.$router.push({
                    path: "/abnormalView",
                    query: queryParams
                });
            } else if (type == 2) {
                if (!queryParams.studentInfo) {
                    if (this.selectItems.length > 0) {
                        this.selectItems.forEach(e => {
                            if (!e.status) {
                                this.$message({
                                    type: "warning",
                                    message: "选择的列表中不能包含已申请的学生"
                                });
                                throw "err";
                            }
                        });
                        queryParams.studentInfo = this.selectItems;
                    } else {
                        this.$message({
                            type: "warning",
                            message: "请先选择需要审批的学生"
                        });
                        return;
                    }
                }
                queryParams.type = "review";
                this.$router.push({
                    path: "/abnormalAudit",
                    query: queryParams
                });
            } else if (type == 3) {
                this.$confirm("确认撤销此条异动信息?", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning"
                }).then(() => {
                    applyApi
                        .cancelApply({
                            id: row.id,
                            studentId: row.studentId,
                            isSysAdmin: this.global.isAdmin + ""
                        })
                        .then(res => {
                            if (res.code == 200) this.getAbnormalList();
                        })
                        .catch(err => {
                            console.log(err);
                        });
                });
            }
        },
        //删除申请
        async deleteApply(row) {
            try {
                const resTip = await this.$confirm(
                    "确认删除此条申请记录?",
                    "提示",
                    {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning"
                    }
                );
                if (resTip == "confirm") {
                    const res = await deleteType({
                        studentId: row.studentId,
                        status: row.status,
                        id: row.id
                    });
                    if (res.code == 200) {
                        this.$message({
                            type: "success",
                            message: res.msg
                        });
                        this.getAbnormalList();
                    }
                }
            } catch (err) {
                console.log(err);
            }
        },
        // 根据学院获取专业
        handleChangeFaculty(val) {
            this.options.profession = [];
            this.multipleQuery.currentProfession = [];
            this.query.currentProfession = "";
            let facultys, degreeType;
            facultys = this.multipleQuery.currentFaculty;
            degreeType = this.query.degreeType ? [this.query.degreeType] : [];
            const data = {
                lang: this.$store.getters.language || "cn",
                type: "allChild",
                keys: ["G_ZY"],
                filter: {
                    prefix: facultys,
                    specilaCode: "XY2ZY",
                    facultys: facultys,
                    grade: this.query.currentGrade,
                    degreeType: degreeType
                }
            };
            queryDic(data).then(res => {
                if (res.code === 200)
                    UTILS.fillSelect(
                        {
                            profession: "G_ZY"
                        },
                        res.data,
                        this.options
                    );
                this.options.profession = this.options.profession.map((item) => {
                    return {
                        key: item.value,
                        label: item.label + "(" + item.value + ")",
                        value: item.value
                    }
                })
            });
        },
        // 获取过滤条件是否展开
        getIsExpand(val) {
            this.isExpand = val;
        },
        // 异动大类变化时的回调，用于根据大类id查询该大类下面所有异动类型
       async handlerClassIdChange(val,ifRouter) {
            this.query.typeId = "";
            this.options.typeId = [];
            this.query.reasonName = "";
            this.options.reasonName = [];
            if (!val) return;
         await API.getAbnormalTypeByClassCode(val).then(res => {
                let { code, data } = res;
                if (code === 200) {
                    this.options.typeId = data.map(e => {
                        return {
                            label: e.label,
                            value: e.typeId,
                            key: e.value
                        };
                    });
                }

            });
            if (ifRouter === 'ifRouter') {
                if(this.$route.query.routerQuery && this.$route.query.routerQuery.typeId) {
                    this.handlerAbnormalType(this.$route.query.routerQuery.typeId)
                }
                if(this.$route.query.routerQuery) {
                this.query = _.cloneDeep(this.$route.query.routerQuery)
                typeof(this.query) === 'string' ? this.query = JSON.parse(this.query) : ''
                }

                if(this.$route.query.extralQuery) {
                this.multipleQuery = _.cloneDeep(this.$route.query.extralQuery)
                typeof(this.multipleQuery) === 'string' ? this.multipleQuery = JSON.parse(this.multipleQuery) : ''
                }

            }
            this.getAbnormalList()
        },
        // 异动类型改变获取异动原因
        handlerAbnormalType(val) {
            this.query.reasonName = "";
            this.options.reasonName = [];
            if (!val) return;
            let obj = this.options.typeId.find(t => t.value == val);
         API.getAbnormalReason(obj.key).then(res => {
                let { code, data } = res;
                if (code === 200 && data) {
                    data.forEach(item => {
                        this.options.reasonName.push({
                            label: item.reason,
                            value: item.id
                        });
                    });
                }
            });
        },
        // 筛选
        filetrCondition() {
            this.query.pageNum_ = 1;
            this.getAbnormalList();
        },
        // 重置
        reset() {
            let multipleQuery = this.multipleQuery;
            let query = this.query;
            for (var key in multipleQuery) {
                multipleQuery[key] = [];
            }
            query.currentGrade = '';
            query.trainingLevel = '';
            query.currentFaculty = '';
            query.currentProfession = '';
            query.trainingLevel = '';
            query.trainingCategory = '';
            query.degreeType = '';
            query.formLearning = '';
            query.classId = '';
            query.status = '';
            query.typeId = '';
            query.reasonName = '';
            query.abnormalStartTime = '';
            query.abnormalEndTime = '';
            query.operateStartTime = '';
            query.operateEndTime = '';
            query.keyWord = '';
            query.isStudent = '';
            query.currentUuid = '';
            query.internationalStudent = '';
            this.options.profession = [];
            this.options.typeId = [];
            this.options.reasonName = [];
            this.getAbnormalList();
        },
        // 获取异动管理列表
        getAbnormalList() {
            let params = _.cloneDeep(this.query);
            params.currentFaculty = this.multipleQuery.currentFaculty + "";
            params.currentProfession =
                this.multipleQuery.currentProfession + "";
            params.trainingLevel = this.multipleQuery.trainingLevel + "";
            params.isStudent = this.global.isStudent;
            if (
                params.abnormalStartTime &&
                params.abnormalEndTime &&
                params.abnormalEndTime < params.abnormalStartTime
            ) {
                this.$message({
                    type: "warning",
                    message: "请检查筛选的异动时间"
                });
                return;
            }
            if (
                params.operateStartTime &&
                params.operateEndTime &&
                params.operateEndTime < params.operateStartTime
            ) {
                this.$message({
                    type: "warning",
                    message: "请检查筛选的审核时间"
                });
                return;
            }
            if (params.abnormalEndTime) {
                params.abnormalEndTime =
                    params.abnormalEndTime + 24 * 60 * 60 * 1000 - 1;
            }
            if (params.operateEndTime) {
                params.operateEndTime =
                    params.operateEndTime + 24 * 60 * 60 * 1000 - 1;
            }
            this.sendApplyRequest(params);
        },
        async sendApplyRequest(params) {
            let {
                code,
                data: { list, total_ }
            } = await applyApi.applyList(params);
            if (code !== 200) return;
            if (global.isAdmin && !overSeas) {
                await this.getCurrentTerm();
                list.forEach(e => this.judgeRevocationStatus(e));
            }
            this.abnormalManageList = {
                total: total_,
                data: list
            };
        },
        //获取当前学期数据
        async getCurrentTerm() {
            const _this = this;
            const {
                code,
                data: {
                    schoolCalendar: { beginDay, endDay }
                }
            } = await Calendars.currentTermCalendar();
            if (code == 200) _this.termTime = { beginDay, endDay };
        },
        judgeRevocationStatus(params) {
            let result = false;
            let _this = this;
            let key = params.revocationTimeLimit;
            let applyTime = new Date(params.createTimeFormart);
            let now = new Date().getTime();
            if (key == "week") {
                let weekIns = now - applyTime.getTime();
                result = weekIns < 7 * 24 * 60 * 60 * 60;
            } else if (key == "month") {
                let applyMonth = applyTime.getMonth();
                let nowMonth = new Date().getMonth();
                result = nowMonth - applyMonth == 0;
            } else if (key == "term") {
                result =
                    now > _this.termTime.beginDay &&
                    now < _this.termTime.endDay;
            } else if (key == "year") {
                let applyYear = applyTime.getFullYear();
                let nowYear = new Date().getFullYear();
                result = nowYear - applyYear == 0;
            }
            return Object.assign(params, { revocateBtnStatus: result });
        },
        pageChange(val) {
            this.query.pageSize_ = val.pageSize;
            this.query.pageNum_ = val.pageNum;
            this.getAbnormalList();
        },
        handleSelectionChange(val) {
            this.selectItems = val;
        },
        makeSureImport() {
            this.disBtn = true;
            var fd = new FormData();
            fd.append('file', this.importFile);
            applyApi.importApply(fd).then(res=> {
                if(res.code === 200) {
                    this.$message({
                    message: "上传成功！",
                    type: "success"
                    });
                    this.importSure = false;
                    this.disBtn = false;
                    this.getAbnormalList();
                }  else {
                    this.disBtn = true
                }
            })
        },
        // 导入按钮组操作
        handleImportCommand(command) {
            if (command === "download") {
                applyApi.downloadTemplate();
            } else if (command === "import") {

                this.$refs.importBtn.click();
            }
        },
        // 文件导入成功
        handlerSuccess(response, file, fileList) {
            let responseCode = response.code;
            if (responseCode === 200) {
                this.dataList = response.data;
                this.importFile = file.raw;
                this.disBtn = false;
                this.importSure = true
            } else {
                this.$message({
                    message: response.msg,
                    type: "error"
                });
            }
            // this.getAbnormalList();
            this.$refs.upload.clearFiles();
        },
        // 文件导入错误
        handlerError(response, file, fileList) {
            this.$message({
                message: "上传失败！",
                type: "error"
            });
            if (this.uploadType) {
                this.$refs.uploadEdit.clearFiles();
                return;
            }
            this.$refs.upload.clearFiles();
        },
        beforeUpload(file) {
            return UTILS.checkFile(
                file,
                {
                    name: ".xlsx",
                    size: "10"
                },
                this
            );

        },

        // 导出按钮组操作
        handleExportCommand(command) {
            let exportParams = _.clone(this.query);
                exportParams.currentFaculty = this.multipleQuery.currentFaculty.join(',');
                exportParams.currentProfession = this.multipleQuery.currentProfession.join(',');
                exportParams.trainingLevel = this.multipleQuery.trainingLevel.join(',');

            if (this.selectItems.length) {
                let length = this.selectItems.length;
                let ids = "";
                this.selectItems.forEach((e, i) => {
                    if (length - 1 == i) {
                        ids += `${e.id}`;
                    } else {
                        ids += `${e.id},`;
                    }
                });
                exportParams.ids = ids;
            } else {
                exportParams.ids = "";
            }
            if (command === "applyList") {
                //导出异动申请列表
                applyApi.exportClass("apply/exportApplyXlsx", exportParams);
            } else if (command === "studentStatusList") {
                //学籍异动申请表
                applyApi.exportClass(
                    "apply/exportApplyDocxZip",
                    Object.assign(exportParams, { exportType: 0 })
                );
            } else if (command === "studentStatusNotification") {
                //研究生 学籍异动通知单
                applyApi.exportClass(
                    "apply/exportApplyDocxZip",
                    Object.assign(exportParams, { exportType: 1 })
                );
            } else if (command === "enrolment") {
                //在校学籍异动DBF
                applyApi.exportClass(
                    "apply/abnormalDbfExport",
                    Object.assign(exportParams, {
                        exportKind: "atSchool"
                    })
                );
            } else if (command === "revoked") {
                //注销学籍异动DBF
                applyApi.exportClass(
                    "apply/abnormalDbfExport",
                    Object.assign(exportParams, {
                        exportKind: "logoutAbnormal"
                    })
                );
            } else if(command === "underStatusNotification") {

                //本科生 学籍异动通知单
                applyApi.exportClass(
                    "apply/exportAbnormalDocxZip",
                    Object.assign(exportParams)
                );

            }
        },
        showUserGroup(groupId = "") {
            // this.queryUserForm.groupId = groupId;
            this.$set(this.queryUserForm, "groupId", groupId);
            this.showUserGroupDialog = true;
            this.getUserInfoListByGroupId();
        },
        /**
         * params {groupId 用戶組ID}
         * 根据用户组iD 查询用户
         */
        async getUserInfoListByGroupId() {
            try {
                if (!this.queryUserForm.groupId) {
                    this.$message({
                        type: "error",
                        message: "查询出错, 请重试."
                    });
                    return;
                }
                let { code, data } = await getUserInfoListByGroupId(
                    this.queryUserForm
                );
                if (code == 200) {
                    this.usersUnderGroup = data ? data.list : [];
                    this.queryUserForm.total = data.total_;
                }
            } catch (err) {
                this.$message({
                    type: "error",
                    message: "查询出错, 请重试."
                });
            }
        },
        pageChangeDialog(val) {
            this.queryUserForm.pageSize_ = val.pageSize;
            this.queryUserForm.pageNum_ = val.pageNum;
            this.getUserInfoListByGroupId();
        }
    },
    directives: {
        border(el, binding) {
            if (el.offsetLeft === 0) {
                el.style.borderLeft = "1px solid #dcdfe6";
            }
        }
    },
    filters: {
        getStatus(val) {
            let status = "";
            switch (val) {
                case "0":
                    status = "草稿";
                    break;
                case "1":
                    status = "审核中";
                    break;
                case "2":
                    status = "驳回";
                    break;
                case "3":
                    status = "已审核";
                    break;
                case "4":
                    status = "导师审核";
                    break;
                case "5":
                    status = "学院审核";
                    break;
                case "6":
                    status = "留办审核";
                    break;
                case "7":
                    status = "转入学院审核";
                    break;
                case "8":
                    status = "学校审核";
                    break;
                case "9":
                    status = "已撤销";
                    break;
                case "10":
                    status = "校医审核";
                    break;
                default:
                    status;
            }
            return status;
        }
    },
    computed: {
        currentUser() {
            if (this.$store.state.session.user) {
                return this.$store.state.session.user;
            }
            return JSON.parse(localStorage.getItem("user"));
        },
        mockUser() {
            if (this.$store.state.session.mockUser) {
                return this.$store.state.session.mockUser;
            }
            let sessiondata = JSON.parse(localStorage.getItem("sessiondata"));
            if (sessiondata && sessiondata.mockUser) {
                return sessiondata.mockUser;
            }
        }
    }
};
</script>
<style lang="scss" scoped>
.abnormal-manage {
    .border-bt {
        border-bottom: 1px solid #dcdfe6;
    }
}
</style>
